home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <unistd.h>
- #include <time.h>
- #include <string.h>
-
- char *getword(int, char*, char*);
- char *caps(char[]);
-
-
- void ag_sysdate(char date[])
- {
- time_t t;
- char now[4096];
- char word[256];
- char day[256];
- t=time(NULL);
- strcpy(now,ctime(&t));
- /* strcpy(date,"\'"); */
- strcpy(day,getword(3,now,word));
- if (strlen(day)<2) strcat(date,"0");
- strcat(date,day);
- strcat(date,"-");
- if (strcmp(caps(getword(2,now,word)),"JAN")==0) strcat(date,"01");
- if (strcmp(caps(getword(2,now,word)),"FEB")==0) strcat(date,"02");
- if (strcmp(caps(getword(2,now,word)),"MAR")==0) strcat(date,"03");
- if (strcmp(caps(getword(2,now,word)),"APR")==0) strcat(date,"04");
- if (strcmp(caps(getword(2,now,word)),"MAY")==0) strcat(date,"05");
- if (strcmp(caps(getword(2,now,word)),"JUN")==0) strcat(date,"06");
- if (strcmp(caps(getword(2,now,word)),"JUL")==0) strcat(date,"07");
- if (strcmp(caps(getword(2,now,word)),"AUG")==0) strcat(date,"08");
- if (strcmp(caps(getword(2,now,word)),"SEP")==0) strcat(date,"09");
- if (strcmp(caps(getword(2,now,word)),"OCT")==0) strcat(date,"10");
- if (strcmp(caps(getword(2,now,word)),"NOV")==0) strcat(date,"11");
- if (strcmp(caps(getword(2,now,word)),"DEC")==0) strcat(date,"12");
- strcat(date,"-");
- strcat(date,getword(5,now,word));
- date[strlen(date)-1]=0;
- /* strcat(date,"\'"); */
-
- }
-
- void ag_systime(char timev[])
- {
- time_t t;
- char now[4096];
- char word[256];
- t=time(NULL);
- strcpy(now,ctime(&t));
- /* strcpy(timev,"\'"); */
- strcpy(timev,getword(4,now,word));
- /* strcat(timev,"\'"); */
-
- }
-
-
- char *getword(int word_number, char *line, char *word)
- {
- int a,b,c,in_quotes=0;
- b=0;
- for (a=0; a<256; a++) word[a]=0;
- a=0;
- c=0;
- while(a<strlen(line)) {
- if (!in_quotes) if ((line[a]==' ') || (line[a]=='\t')) {
- while (((line[a]==' ')||(line[a]=='\t'))&&(a<strlen(line))) a++;
- word[b]=0;
- b=0;
- c++;
- if (c==word_number) return(word);
- }
- if (in_quotes) if (line[a]=='\"') {
- a++;
- while (((line[a]==' ')||(line[a]=='\t'))&&(a<strlen(line))) a++;
- word[b]='\"';
- b++;
- word[b]=0;
- b=0;
- c++;
- in_quotes=0;
- if (c==word_number) return(word);
- }
- if (line[a]=='\"') {
- if (in_quotes==1) in_quotes=0;
- else in_quotes=1;
- }
- word[b]=line[a];
- b++;
- a++;
- }
- word[b]=0;
- return(word);
- }
-
-
- char *caps(char* var1)
- {
- int a;
- char var[256];
- strcpy(var, var1);
- for (a=0; a<strlen(var); a++) if (var[a]>=97) var[a]-=97-65;
- return(var);
- }
-
-